#include "sr.h"

void
emstopMergerFire(int *craneKnownFlags, int *cranePresentFlags) {
    
    if(GET_BIT(*craneKnownFlags, EMSTOPCHECKPOSDESIREDBIT) && 
            GET_BIT(*craneKnownFlags, EMSTOPCHECKMINMAXBIT)) {

        if(GET_BIT(*cranePresentFlags, EMSTOPCHECKPOSDESIREDBIT)) {
            SET_BIT_TRUE(*cranePresentFlags, EMSTOPMERGERBIT);
            SET_BIT_TRUE(*craneKnownFlags, EMSTOPMERGERBIT);
        }
        
        if(GET_BIT(*cranePresentFlags, EMSTOPCHECKMINMAXBIT)) {
            SET_BIT_TRUE(*cranePresentFlags, EMSTOPMERGERBIT);
            SET_BIT_TRUE(*craneKnownFlags, EMSTOPMERGERBIT);
        }
    }

    if(GET_BIT(*craneKnownFlags, EMSTOPCHECKPOSDESIREDBIT) && 
            GET_BIT(*craneKnownFlags, EMSTOPCHECKMINMAXBIT) &&
            !GET_BIT(*craneKnownFlags, EMSTOPMERGERBIT)) {
        SET_BIT_TRUE(*craneKnownFlags, EMSTOPMERGERBIT);
    }
}
